package com.neuedu.corejava.ch14.homework;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import java.net.Socket;
import java.util.Scanner;

public class NetTools {

	static void closeAll(Scanner scanner, Socket socket, InputStream inputStream,
			OutputStream outputStream) {

		if (outputStream != null) {
			if(scanner!=null) {
				scanner.close();
			}
			try {
				socket.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (outputStream != null) {
					try {
						outputStream.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
					
					

				}
			}
		}
	}
}
